package edu.nf.ch02.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ViewResolverRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.view.InternalResourceViewResolver;

/**
 * @author wangl
 * @date 2025/5/9
 * SpringMVC配置类
 */
@Configuration
//启用mvc注解驱动
@EnableWebMvc
public class MvcConfig implements WebMvcConfigurer {

    /**
     * 注册内部资源视图解析器
     * @param registry
     */
    @Override
    public void configureViewResolvers(ViewResolverRegistry registry) {
        //实例化内部资源视图解析器
        InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
        //设置前缀
        viewResolver.setPrefix("/WEB-INF/jsp/");
        //设置后缀
        viewResolver.setSuffix(".jsp");
        //注册视图解析器
        registry.viewResolver(viewResolver);
    }
}